#pragma once
#ifndef __VSTATICMESH_H__
#define __VSTATICMESH_H__

// Static Mesh Data.
class VCoreApi VStaticMesh : public VAllocator
{
public:
	VStaticMesh(void);
	~VStaticMesh(void);

	BOOL LoadMesh(const char* FileName);
	BOOL LoadMesh(VStream& Stream);

	void Clear();
	

	// Common Vertex
	struct VertexCommon
	{
		VVector3 Position;
		VByteVector Normal;
		VVector2 TexCoord;
	};

	struct TriFace
	{
		int VertexIndex[3];
	};



	struct Vertex 
	{
		VVector3 Position;			// coordinate
		VByteVector Normal;		// normal
		VByteVector Tangent;		// tangent
		VVector4 Texcoord;		// texture coordinates
	};

	struct Surface : public VAllocator
	{
		int NumVertics;					// vertices
		Vertex* Vertics;
		int NumIndics;				// indices
		int* Indices;				// if NumVertics < 65536  the Indices is WORD*
		int NumTexCoords;
		//Vector<Node> nodes;				// spatial tree
		//Vector<Triangle*> ntriangles;	// node triangles
		VBoundBox		BoundBox;				// bounds
		VBoundSphere	BoundSphere;

		inline bool IndicesIsWord() const { return NumVertics < 65536; }
	};
	inline const Surface& GetSurface(UINT Index) const { return m_Surfaces[Index]; } 
protected:
	VBoundBox		m_BoundBox;
	VBoundSphere	m_BoundSphere;
	Surface*		m_Surfaces;
	int				m_NumSurfaces;
};




#endif 
